/**
 * Sample Skeleton for "MiscelliniousTab.fxml" Controller Class
 * You can copy and paste this code into your favorite IDE
 **/

package com.pentofab.payrollmanagement.ui.controller;

import java.net.URL;
import java.util.ResourceBundle;

import com.pentofab.payrollmanagement.application.PayrollApplicationFactory;
import com.pentofab.payrollmanagement.dao.model.Company;
import com.pentofab.payrollmanagement.dao.model.UserAccounts;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;


public class MisceliniousTabController extends AbstractUIController
    implements Initializable {

    @FXML
    private ListView<String> listView;
    @FXML
    private VBox root;

    private Company company;
    private UserAccounts userAccounts;

    public void goBack(ActionEvent event) {

		PayrollApplicationFactory.getMainController().showScreen(
				MainController.COMPANIES_LIST_SCREEN, false, userAccounts);
	
    }
    
    @Override
	public void refreshUI(Object... args) {
		
		if (args != null && args.length > 0) {
			Company company = (Company) args[0];
			this.company = company;
			
			if(args.length > 1 && args[1] instanceof UserAccounts){
				userAccounts = (UserAccounts) args[1];
			}
		}

	}

    public void open() {
    	
    	if(listView.getSelectionModel().getSelectedIndex() == 0){
    		
    		PayrollApplicationFactory.getMainController().showScreen("Holidays.fxml", true, company,userAccounts);
    	}else if(listView.getSelectionModel().getSelectedIndex() == 1){
    		
    		PayrollApplicationFactory.getMainController().showScreen("PTaxSlab.fxml", true, company,userAccounts);
    	}else if(listView.getSelectionModel().getSelectedIndex() == 2){
    		
    		PayrollApplicationFactory.getMainController().showScreen("ESIPFBONUS.fxml", true, company,userAccounts);
    	}
    	
    	else {
    		showError("Please select a module to view.");
    	}
    }

    public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
    	
    	
    	listView.getItems().add("HOLIDAYS");
    	listView.getItems().add("Professional TAX Slab");
    	listView.getItems().add("ESI PF Bonus");
    	
    }

	@Override
	public Parent getView() {
		
		return root;
	}

	@Override
	public String getTitle() {
		
		return "Others";
	}

}
